package cn.wolfcode.luowowo.comment.domain;

import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.util.StringUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Setter
@Getter
@Document("scenic_comment")
public class ScenicComment implements Serializable {
    public static final Integer TRAVEL_NOMAL_TYPE = 0; //普通评论
    public static final Integer TRAVEL_COMMENT_TYPE = 1; //回复评论

    @Id     //_id
    private String id;

    private Long scenicId;      //景点id

    private Long userId;        //评论者id

    private String username;    //评论者昵称

    private String headUrl;     //评论者头像

    private Integer level;      //评论者等级

    private Integer rank;      //评价星数

    private String commentUrl;   //评价图片

    private String[] commentUrls;

    private Date createTime;    //创建时间

    private String content;     //评论内容

    private Integer thumbupnum = 0;     //点赞数

    private List<Long> thumbuplist = new ArrayList<>();     //点赞的用户id集合

    private Integer type = TRAVEL_NOMAL_TYPE; //用来判断是普通评论还是回复评论

    private ScenicComment refComment; //回复谁的评论

    private String refCommentId;

    private List<ScenicComment> comments = new ArrayList<>(); //评论的评论


    public String[] getCommentUrls() {
        if (StringUtils.hasLength(commentUrl)) {
            return commentUrl.split(",");
        }
        return null;
    }
//    public String getCommentUrl(){
//        if(commentUrls!=null){
//            return StringUtils.arrayToDelimitedString(commentUrls, ",");
//        }
//        return null;
//    }
}
